<?php
namespace common\services\lifang;
use common\models\Common;
use linslin\yii2\curl\Curl;

/**
 * 腾讯云
 * Created by PhpStorm.
 * User: eycuit
 * Date: 2020/2/27
 * Time: 15:14
 */

class LiFang extends Common {

    public $accessToken = '19ba2fba46d348b8972729dfbddec24e';
    public $appSecret = '8oRTQlpYiBKQRgFSbzXB2L9nF8nqvEQS';
    public $api = 'http://api.bm001.com/api';

    protected function getBaseParams($method = '', $serverParams = '') {

        $params = [
            "method" => $method,
            "v" => '1.1',
            "access_token" => $this->accessToken,
            "timestamp" => date("Y-m-d H:i:s")
        ];

        $params = array_merge($params, $serverParams);

        $sign = $this->getSign($params);
        $params['sign'] = $sign;

        return $params;
    }

    protected function getSign($params = []) {
        ksort($params);

        $signStr = '';
        foreach ($params as $k => $v) {
            $signStr .= $k . $v;
        }

        $sign = strtoupper(sha1($this->appSecret . $signStr . $this->appSecret));

        return $sign;
    }
}